--lua script
--使用报警器

--#include "data\config\friend\AlarmItem.lua" once --BUFF配置表
--#include "data\functions\Activity\Common\Consumes.lua" once

--[[
--添加buff的物品
--sysarg:实体的指针
--itemidx: 物品的ID
--itemPtr: 物品的指针
--ItemTable: 配置的参数列表 
--]]
function UseAlarmItem(sysarg,itemidx,itemPtr,ItemTable)
	if(Actor.getItemCount(sysarg,ItemTable.item_id) == 0) then
		Actor.sendTipmsg( sysarg,Lang.ScriptTips.x00013,ttTipmsgWindow )
		return
	end

	 Actor.addBuff(sysarg,ItemTable.buffType,ItemTable.buffGroup, ItemTable.value, ItemTable.times, ItemTable.interval, Item.getItemName(itemidx), ItemTable.timeOverlay) --添加buff

	 if ItemTable.needConsume == true then
		Actor.removeItemByPtr(sysarg,itemPtr,1,true,"AlarmItem",5)
	 end
end

function UseAlarmItemInit(sysarg)
  for i = 1,table.getn(AlarmItemConfig) do
	local x = AlarmItemConfig[i]
	GlobalItemFn[x.item_id] = { func = UseAlarmItem, params = x }
  end
end

table.insert(InitFnTable,UseAlarmItemInit)